# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=rpcbind
pkgver=1.2.7
pkgrel=0
pkgdesc="portmap replacement which supports RPC over various protocols"
url="https://rpcbind.sourceforge.net/"
arch="all"
options="!check"  # No test suite.
license="BSD-3-Clause"
install="$pkgname.pre-install $pkgname.pre-upgrade"
makedepends="libtirpc-dev autoconf automake bsd-compat-headers"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-openrc"
source="https://downloads.sourceforge.net/project/rpcbind/rpcbind/$pkgver/rpcbind-$pkgver.tar.bz2
	rpcbind.initd
	rpcbind.confd
	"

# secfixes:
#   0.2.4-r0:
#     - CVE-2017-8779

prepare() {
	default_prepare
	sh autogen.sh
}

build() {
	unset CC
	unset CFLAGS
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--bindir=/sbin \
		--sbindir=/sbin \
		--enable-warmstarts \
		--with-statedir=/var/lib/rpcbind \
		--with-rpcuser=rpc \
		--enable-debug \
		--with-systemdsystemunitdir='no'
	make -j1
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/rpcbind.initd "$pkgdir"/etc/init.d/rpcbind
	install -Dm644 "$srcdir"/rpcbind.confd "$pkgdir"/etc/conf.d/rpcbind
	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/rpcbind/COPYING
}

sha512sums="
ca1517bdab86221d13c645042cc31b25b4d2b574d63ebaa20da4f5392b611cf58811f267214293e953f504d364e5daaa5875eab7aa68a04b89e68fd5508e3926  rpcbind-1.2.7.tar.bz2
1cd655d86226a45fa3e927f8ac2bb580537644d2fb3684e0f4a956bf3721c95d95b8b8c1d9a2a742fb714eeba9277e0400a7493bf1bf676466d70adb2b35a88e  rpcbind.initd
0641087162ebc8fb10c5cb329105261d77cad073daed3f9a6c92574177298cd8a19a87b62dde14161cc554b5e68680cfd870b5334f3cfd8d6074ec8a43f4dfe3  rpcbind.confd
"
